#include<string.h>
#include<stdlib.h>

char *largestGoodInteger(char *num)
{
    int count = 1;
    char max = 0;

    for (int i = 1; i < strlen(num); i++)
    {
        if (num[i] == num[i - 1])
        {
            count++;
            if (count == 3 && num[i] > max)
            {
                max = num[i];
            }
        }
        else
            count = 1;
    }

    char *ans = NULL;
    ans = (char *)calloc(4, sizeof(char));
    ans[0] = ans[1] = ans[2] = max;
    ans[3] = '\0';
    // printf("%c",max);
    return ans;
}